package com.module.prms;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import org.apache.log4j.Logger;

import base.util.ResolveUnit;

import com.activityClient.client.ActivityThread;
import com.module.prms.manager.MenuManager;
import com.module.prms.vo.FMenuTree;
import com.module.prms.vo.PrmsMenu;
import com.module.sys.ConstantUnit;
import com.webClient.client.SocketClient;
import com.webClient.service.WebClientService;



public class prmsMenuService {
	static SocketClient sClient = null;
	static WebClientService ss = null;
	static Logger logger = Logger.getLogger(prmsMenuService.class.getName ()) ;
	 
	 public List list() throws Exception{
		MenuManager menuManager = MenuManager.getInstance();
		FMenuTree ft=menuManager.list();
  	    return ft.getTree();
	 }
	 
	 
	public PrmsMenu findbyid(String id) {
		MenuManager menuManager = MenuManager.getInstance();
		PrmsMenu obj = new PrmsMenu();
		obj.setCmenuId(id);
		PrmsMenu pm = new PrmsMenu();
		try {
			pm = menuManager.findebyid(obj);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return pm;
	}
	 
	 public Map save(PrmsMenu obj)
	 {
		 MenuManager menuManager = MenuManager.getInstance();
		 boolean isTrue=false;
		try {
			isTrue = menuManager.add(obj);
		} catch (Exception e) {
			e.printStackTrace();
		}
		 Map<String, Object> statusMap = new HashMap<String, Object>();
		 statusMap.put("state", isTrue);
		 if (isTrue == true) {
			statusMap.put("msg", "保存成功");
		 } else {
			statusMap.put("msg", "保存失败");
		 }
		 return statusMap;
	 } 

	public Map remove(List<String> idArray) throws Exception {
		MenuManager menuManager = MenuManager.getInstance();
		boolean isTrue = menuManager.remove(idArray);
		Map<String, Object> statusMap = new HashMap<String, Object>();
		statusMap.put("state", isTrue);
		if (isTrue == true) {
			statusMap.put("msg", "删除成功");
		} else {
			statusMap.put("msg", "删除失败");
		}
		return statusMap;
	}

}
